import java.util.Arrays;
import java.util.Scanner;

public class p1161 {
    public static void main(String[] args) {
        int n, t, max = 0;
        double a;
        boolean[] vis = new boolean[10000000];
        Arrays.fill(vis, false);
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        for (; n > 0; n--) {
            a = input.nextDouble();
            t = input.nextInt();
            int _a = (int) a;
            max = (int)(a * t) > max ? (int)(a * t) : max;
            for (int i = 1; i <= t; i++) {
                vis[(int)(a * i)] = !vis[(int)(a * i)];
            }
        }
        for (int i = 1; i <= max; i++) {
            if (vis[i] == true){
                System.out.println(i);
                break;
            }
        }
    }
}